<template>
  <div class="tips">
    <group gutter="0">
      <x-textarea class="tips_text" placeholder="请输入小于200个字汉字" v-model="value" :max="200" :height="198"></x-textarea>
    </group>
    <x-button type="primary" class="btn_sure" :disabled="btnUse" @click.native="nextPage">确定</x-button>
    <x-button class="btn_next" @click.native="jumpPage">跳过</x-button>
  </div>
</template>

<script>
import { XTextarea, Group, XButton } from "vux";
export default {
  data() {
    return {
      value: "",
      canEdit: false,
      clubValue: {}
    };
  },
  components: {
    XTextarea,
    Group,
    XButton
  },
  computed: {
    btnUse() {
      return this.value ? false : true;
    }
  },
  created() {
    this.clubValue = this.apiService.getSessionData("clubValue");
    this.canEdit = location.href.split("?")[1] ? true : false;
    this.value = this.clubValue.describe;
  },
  beforeRouteLeave(to, from, next) {
    this.apiService.setSessionData("clubValue", this.clubValue);
    next();
  },
  methods: {
    nextPage() {
      this.clubValue.describe = this.value;
      if (this.canEdit) {
        let clubId = this.clubValue.clubId;
        if (clubId) {
          this.apiService.club
            .editclub({
              clubid: clubId,
              describe: this.value
            })
            .then(res => {
              this.$router.go(-1);
            });
        } else {
          this.$router.go(-1);
        }
      } else {
        this.$router.push("switch");
      }
    },
    jumpPage() {
      if (this.canEdit) {
        this.$router.go(-1);
      } else {
        this.$router.push("switch");
      }
    }
  }
};
</script>


<style scoped>
.tips {
  padding: 0.3rem;
}
.btn_sure {
  margin-top: 0.3rem;
}
.tips_text {
  font-size: 0.24rem;
}
</style>

